/* GameAction.java
 * 
 * Alfred Olschnoegger
 * 02.06.2008
 */

package presentation.controller;

import exceptions.RabbitBusterException;
import application.GameInfoProvider;
import application.parser.Parser;
import application.parser.StringParser;

/**
 * TODO description
 *
 * @date 02.06.2008
 * @author Alfred Olschnoegger
 */

public class GameAction extends HttpBaseController {

	@Override
	public void process() {
		StringParser parse = new StringParser();
		try {
			GameInfoProvider prov = new GameInfoProvider(Integer.parseInt(m_Arguments.get("game")));
			if(m_Arguments.get("task").equalsIgnoreCase("use")) {
				String hunter = m_Arguments.get("username");
				int object = Integer.parseInt(m_Arguments.get("object"));
				int p_X = Integer.parseInt(m_Arguments.get("x"));
				int p_Y = Integer.parseInt(m_Arguments.get("y"));
				
				prov.use(object,hunter,p_X, p_Y, parse);
			}
		} catch ( RabbitBusterException e) {
			StringParser pars= new StringParser();
			pars.add(e);
		}
		
		m_Request.setAttribute("responseStr",parse.parse());
		redirect();
	}

}


// end of GameAction.java
